package ferran.tomas.ta;

import java.io.FileNotFoundException;
import java.io.IOException;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore.Images.Media;
import android.view.View;
import android.widget.Toast;

public class MainMenu extends Activity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mainmenu);
	}


	public void go_photo(View v) {
		Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
		photoPickerIntent.setType("image/*");
		startActivityForResult(photoPickerIntent, 1);
	}
	protected void onActivityResult(int requestCode, int resultCode, Intent data)
	{
	    super.onActivityResult(requestCode, resultCode, data);
	    if (resultCode == RESULT_OK)
	    {
	        Uri chosenImageUri = data.getData();

	        Bitmap mBitmap = null;
	        try {
				mBitmap = Media.getBitmap(this.getContentResolver(), chosenImageUri);
				Toast.makeText(this, "Image uploaded successfully",
						Toast.LENGTH_SHORT).show();
				
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	        }
	}
	
	public void go_location(View v) {
		Intent intent = new Intent(MainMenu.this, MapaActivity.class);
		MainMenu.this.startActivity(intent);
	}

	public void go_products(View v) {
		Intent intent = new Intent(MainMenu.this, Products.class);
		MainMenu.this.startActivity(intent);
	}

	public void go_contacts(View v) {
		Intent intent = new Intent(MainMenu.this, Contacts.class);
		MainMenu.this.startActivity(intent);
	}
	public void go_events(View v) {
		Intent intent = new Intent(MainMenu.this, Events.class);
		MainMenu.this.startActivity(intent);
	}
	
	public void go_calendar(View v) {
		//startActivity(new Intent(Intent.ACTION_VIEW).setDataAndType(null, CalendarActivity.MIME_TYPE));
		
		
		
		//Intent intent = new Intent(MainMenu.this, TestActivity.class);
		//MainMenu.this.startActivity(intent);
	}
}
